{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">栏目管理</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <div class="alert alert-success-light">添加、修改和删除栏目全部完成后，请点击【更新栏目缓存】！</div>
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
        </div>
    </div>
</div>
<script type="text/html" id="barTool">
    <a data-open="{{d.add_url}}" data-width="900" data-height="600" class="layui-btn layui-btn-xs layui-btn-normal" title="添加子栏目">添加子栏目</a>
    <a data-open='{:url("edit")}?id={{ d.id }}' data-width="900" data-height="600" class="layui-btn layui-btn-xs" title="编辑"><i class='iconfont icon-brush_fill'></i></a>
    <a href='{:url("del")}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del"><i class='iconfont icon-trash_fill'></i></a>
</script>
{/block}
{block name="script"}
<script>
layui.use('yznTable', function() {
    var yznTable = layui.yznTable;

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTable',
        delete_url: "{:url('del')}",
        modify_url: '{:url("multi")}',
    };

    yznTable.render({
        init: init,
        toolbar: ['refresh',
            [{
                    text: '新增栏目',
                    url: "{:url('add')}",
                    method: 'open',
                    class: 'layui-btn layui-btn-sm layui-btn-normal',
                    icon: 'iconfont icon-add',
                    extend: 'data-width="900" data-height="600"',
                }], 'delete', [{
                    text: '栏目授权',
                    url: "{:url('cat_priv')}",
                    method: 'open',
                    class: 'layui-btn layui-btn-sm layui-btn-normal',
                    icon: 'iconfont icon-other',
                },
                {
                    text: '栏目数据校正',
                    url: "{:url('count_items')}",
                    method: 'request',
                    class: 'layui-btn layui-btn-sm',
                    icon:'iconfont icon-right',
                    extend: 'data-table="currentTable"',
                },
                {
                text: "更新栏目缓存",
                url: "{:url('public_cache')}",
                method: 'request',
                class: 'layui-btn layui-btn-sm',
                icon:'iconfont icon-shuaxin1',
                extend: 'data-table="currentTable"',
            }]
        ],
        url: '{:url("index")}',
        search:false,
        escape:false,
        cols: [
            [
                { type: 'checkbox', fixed: 'left' },
                { field: 'listorder', width: 70, title: '排序', edit: 'text' },
                { field: 'id', width: 70, title: 'ID' },
                { field: 'catname',align: "left", title: '栏目名称' },
                { field: 'items', width: 80, title: '数据量' },
                { field: 'catdir', width: 120, title: '唯一标识' },
                { field: 'type', width: 90,title: '栏目类型',templet: yznTable.formatter.label,selectList:{1:'单页',2:'列表',3:'外链'},custom:{1:"cyan",2:"blue",3:"green"},search:false},
                { field: 'modelname', width: 120, title: '所属模型' },
                { field: 'url', width: 60, align: "center", title: 'URL', templet: yznTable.formatter.url },
                { field: 'status', width: 100, align: "center", title: '状态', unresize: true,templet: yznTable.formatter.switch },
                { fixed: 'right', width: 170, title: '操作', toolbar: '#barTool' }
            ]
        ],
    });
});
</script>
{/block}